home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 January: Mac OS SDK / Dev.CD Jan 96 SDK / Dev.CD Jan 96 SDK1.toast / Development Kits (Disc 1) / MacODBC / ODBC Tools / SampleDriver / SampleDriver.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-28  |  1.6 KB  |  76 lines  |  [TEXT/MPS ]

  1. #include "ODBCSharedLibraries.h"
  2.  
  3. #if PPCODBC
  4.  
  5. #include <Memory.h>
  6. #include <Errors.h>
  7.  
  8. Handle hinst;
  9.  
  10. // _____________________________________________________________________________
  11.     OSErr
  12.     SampleDriverInit( InitBlockPtr ib )
  13. {
  14.     /*
  15.      *    shared library init function.  All shared libraries should have one.  Its name is
  16.      *    declared in the .exp file.
  17.      */
  18.  
  19.     if ( ib->fragLocator.where != kOnDiskFlat ) { return -32323; }
  20.     
  21.     hinst = NewHandle( sizeof( ODBCLibConnection ) );
  22.     if ( ! hinst ) { return memFullErr; }
  23.     HLock( hinst );
  24.     
  25.     (*(ODBCLibConnection**)hinst)->spec = *ib->fragLocator.u.onDisk.fileSpec;
  26.     (*(ODBCLibConnection**)hinst)->connId = ib->connectionID;
  27.     
  28.     HUnlock( hinst );
  29.     
  30.     return noErr;
  31. }
  32.  
  33.  
  34. // _____________________________________________________________________________
  35.     void 
  36.     SampleDriverMain( ODBCLibConnectionHandle inst2init )
  37. {
  38.     HLock( hinst );
  39.     HLock( (Handle)inst2init );
  40.     **inst2init = **(ODBCLibConnection**)hinst;
  41.     HUnlock( (Handle)inst2init );
  42.     HUnlock( hinst );
  43. }
  44.  
  45.  
  46. #else  // PPCODBC
  47.  
  48. // _____________________________________________________________________________
  49.     void
  50.     SampleDriverInit()
  51. {
  52.     /*
  53.      *    shared library init function.  All shared libraries should have one.  Its name is
  54.      *    declared in the .exp file.
  55.      */
  56.  
  57.     // note: hinst is not needed for the 68k ODBCSharedLibraries functions
  58. }
  59.  
  60. #endif // PPCODBC
  61.  
  62. // _____________________________________________________________________________
  63.     void
  64.     SampleDriverObit()
  65. {
  66.     /*
  67.      *    Shared library cleanup function.  All shared libraries should have one.  Its name is
  68.      *    declared in the .exp file.
  69.      */
  70.      
  71. #if PPCODBC
  72.     DisposHandle( hinst );
  73. #endif // PPCODBC
  74. }
  75.  
  76.